#!/home/hadoop/python26/bin/python
import json
import sys
import mylib

for line in sys.stdin:
    r = None
    try:
        r = json.loads(line.strip())
    except:
        continue
    if r != None:
        key = str(r['id'])
        results = mylib.Twitter.calculate_rt(r)
        if results['rt_user'] != '':
            r['previous_screenname'] = results['rt_user']
            r['mentions'] = results['mentions']
            value = json.dumps(r, sort_keys = False)
            print value
